package com.bitejiuyeke.controller;

import com.bitejiuyeke.common.AppResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 比特就业课
 */
@Api(tags = "测试接口")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation("测试打印")
    @GetMapping("/hello")
    public String hello() {
        return "Hello, Spring boot...";
    }

    @ApiOperation("测试异常")
    @GetMapping("/exception")
    public AppResult testException () throws Exception {
        throw new Exception("这是一个Exception...");
    }

    @ApiOperation("测试自定义异常")
    @GetMapping("/applicationException")
    public AppResult testApplicationException () throws Exception {
        throw new Exception("这是一个ApplicationException...");
    }

    @ApiOperation("测试传参")
    @GetMapping("/helloByName")
    public String testHelloByName (@ApiParam("名字") String name) {
        return "hello," + name;
    }
}
